using UnityEngine;

namespace Naptime.Extensions
{
	public static class GameObjectExtension
	{
		public static void SetActive(this Component component, bool active)
		{
			if (!(component == null))
			{
				component.gameObject.SetActive(active);
			}
		}

		public static T GetOrAddComponent<T>(this GameObject go) where T : Component
		{
			if (!go.TryGetComponent<T>(out var component))
			{
				return go.AddComponent<T>();
			}
			return component;
		}
	}
}
